﻿@model Qu.ComputingContest.Model.Score

@section head {
    <link href="@Url.Content("~/Content/jquery.alerts.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.alerts.js")" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#penaltiesFieldSet input[type=checkbox]').click(function () {
                //console.log($(this).attr('id'));
                //console.log($(this).is(":checked"));
                if ($(this).attr('id') === 'StoppedInFirstHalf' && $(this).is(":checked")) {
                    $('#StoppedInSecondHalf').attr('checked', false);
                }
                if ($(this).attr('id') === 'StoppedInSecondHalf' && $(this).is(":checked")) {
                    $('#StoppedInFirstHalf').attr('checked', false);
                }
                //console.log($(this).attr('id'));
                //console.log($(this).attr('checked'));
                //var ischecked = $(this).is(":checked");
                //$(this).closest('fieldset').find('input[type=checkbox]:checked').each(function () {
                //    $(this).attr('checked', false);
                //});
                //$(this).attr('checked', ischecked);
            });

            $('#message_bar').displayMessage({
                message: '@TempData["Message"]',
                color: 'white',
                speed: 'fast',
                autohide: true,
            });
        });
    </script>
}

@{
    ViewBag.Title = "Scoring";
    Layout = "~/Views/Shared/_LayoutIntranet.cshtml";
}

@if (TempData["Message"] != null)
{
    <b><div id="message_bar">@TempData["Message"]</div></b>
}

<h2>@ViewBag.FormTitle</h2>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.ScoreID)
    @Html.HiddenFor(model => model.TrialID)

    <table width="63%">
        <tr>
            <td width="30%">
                <div class="editor-label">
                    @Html.LabelFor(model => model.RegistrationID, "Team No.")
                </div>
                <div class="editor-field">
                    @Html.DropDownList("RegistrationID", String.Empty)
                    @Html.ValidationMessageFor(model => model.RegistrationID)
                </div>
            </td>
            <td width="30%">
                <div class="editor-label">
                    Run time
                </div>
                @if (ViewBag.FormTitle == "Add Score")
                {
                    <table>
                        <tr>
                            <th>M</th>
                            <th>S</th>
                            <th>1/100 S</th>
                        </tr>
                        <tr>
                            <td><input type="text" name="minutes" maxlength="2" /></td>
                            <td><input type="text" name="seconds" maxlength="2" /></td>
                            <td><input type="text" name="miliseconds" maxlength="2" /></td>
                        </tr>
                    </table>
                }
                else
                {
                    <div class="editor-field">
                        @Html.EditorFor(model => model.RunTime) (Milliseconds)
                        @Html.ValidationMessageFor(model => model.RunTime)
                    </div>
                }
            </td>
        </tr>
    </table>
    <fieldset style="width:63%">
        <legend>Bonuses</legend>
        <div class="editor-field">
            <label>
                @Html.EditorFor(model => model.DispalyCorrectColor) robot displays the correct color on the lcd screen
            </label>
            @Html.ValidationMessageFor(model => model.DispalyCorrectColor)
        </div>
        <div class="editor-field">
            <label>
                @Html.EditorFor(model => model.StopAtCorrectFinishBox) Robot stops in the correct finish box
            </label>
            @Html.ValidationMessageFor(model => model.StopAtCorrectFinishBox)
        </div>
    </fieldset>

    <fieldset id="penaltiesFieldSet" style="width:60%">
        <legend>Penalties</legend>
        <div class="editor-field">
            <label>
                @Html.EditorFor(model => model.StoppedInFirstHalf) Robot has stopped in the First Half of the track (Left half of the track)
            </label>
            @Html.ValidationMessageFor(model => model.StoppedInFirstHalf)
        </div>

        <div class="editor-field">
            <label>
                @Html.EditorFor(model => model.StoppedInSecondHalf) Robot has stopped in the Second Half of the track (Right half of the track)
            </label>
            @Html.ValidationMessageFor(model => model.StoppedInSecondHalf)
        </div>
    </fieldset>
    
    if (ViewBag.IsFinalRound) { 
        <fieldset id="penaltiesForFinalOnly" style="width:60%">
            <legend>Penalties for Final Only</legend>
            <div class="editor-field">
                <label>
                    @Html.EditorFor(model => model.FellOffBridgeWithinTrack) Robot fell off the bridge but inside the track and can continue
                </label>
                @Html.ValidationMessageFor(model => model.FellOffBridgeWithinTrack)
            </div>

            <div class="editor-field">
                <label>
                    @Html.EditorFor(model => model.FailedToDragBlock) Robot failed to drag the block
                    @Html.ValidationMessageFor(model => model.FailedToDragBlock)
                </label>
            </div>
        </fieldset>
    }
    
    @Html.HiddenFor(model => model.UpdatedBy)
    @Html.HiddenFor(model => model.UpdatedDate)
    @Html.HiddenFor(model => model.Year)
    <p>
        <input type="submit" value="Submit" />
    </p>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
